package cn.itsource.pethome.org.service.impl;

import cn.itsource.pethome.org.domain.Employee;
import cn.itsource.pethome.org.mapper.EmployeeMapper;
import cn.itsource.pethome.org.query.EmployeeQuery;
import cn.itsource.pethome.org.service.IEmployeeService;
import cn.itsource.pethome.basic.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @description: 描述:
 * @date: 2020/8/9 14:29
 * @author: summer
 * version: 1.0
 */
@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class EmployeeServiceImpl implements IEmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public PageList<Employee> findAll(EmployeeQuery employeeQuery) {
        Long total = employeeMapper.findCountAll(employeeQuery);
        if(total.equals(0L)){
            return new PageList();
        }
        List<Employee> list = employeeMapper.findAll(employeeQuery);
            return new PageList<Employee>(total, list);
    }

    @Override
    @Transactional
    public void delEmployee(Long id) {
        employeeMapper.delEmployee(id);
    }

    @Override
    @Transactional
    public void batchDelEmployee(Long[] id) {
        employeeMapper.batchDelEmployee(id);
    }

    @Override
    @Transactional
    public void save(Employee employee) {
        employeeMapper.save(employee);
    }

    @Override
    public void update(Employee employee) {
        employeeMapper.update(employee);
    }

}
